package org.weasel.business;

import java.util.ArrayList;

public class Project {
	private String id;
	private String name;
	private ArrayList<Developer> developers;
	private ArrayList<Release> releases;
	private Unscheduled unscheduled;
	private String notes;
	private String startDate;
	private String endDate;
	private int iterationDays; //days per iteration

	public Project(String id, String name, ArrayList<Developer> developers,
			ArrayList<Release> releases, Unscheduled unscheduled, String notes, String startDate, int iterationDays) {
		this.id = id;
		this.name = name;
		this.notes = notes;
		this.startDate = startDate;
		this.iterationDays = iterationDays;
		if (developers != null)
			this.developers = developers;
		else
			this.developers = new ArrayList<Developer>();
		if (releases != null)
			this.releases = releases;
		else
			this.releases = new ArrayList<Release>();
		this.unscheduled = unscheduled;
	}

	public int getIterationDays() {
		return iterationDays;
	}

	public void setIterationDays(int iterationDays) {
		this.iterationDays = iterationDays;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public ArrayList<Developer> getDevelopers() {
		return developers;
	}

	public void setDevelopers(ArrayList<Developer> developers) {
		this.developers = developers;
	}

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<Release> getReleases() {
		return releases;
	}

	public void setReleases(ArrayList<Release> releases) {
		this.releases = releases;
	}

	public Unscheduled getUnscheduled() {
		return unscheduled;
	}

	public void setUnscheduled(Unscheduled unscheduled) {
		this.unscheduled = unscheduled;
	}

	public void addRelease(Release release) {
		releases.add(release);
	}

	public void removeRelease(String id) {
		Release r;
		for (int i = 0; i < releases.size(); i++) {
			r = releases.get(i);
			if (r.getId().equals(id)) {
				releases.remove(i);
				return;
			}
		}
	}

	public Release getRelease(String id) {
		for (Release release : releases) {
			if (release.getId().equals(id))
				return release;
		}
		return null;
	}

	public void addDeveloper(Developer developer) {
		developers.add(developer);
	}

	public void removeDeveloper(String id) {
		Developer d;
		for (int i = 0; i < developers.size(); i++) {
			d = developers.get(i);
			if (d.getId().equals(id)) {
				developers.remove(i);
				return;
			}
		}
	}

	public Developer getDeveloper(String id) {
		for (Developer developer : developers) {
			if (developer.getId().equals(id))
				return developer;
		}
		return null;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

}
